<?php
require_once("/home/bluecbhv/Jcuhelpers-WebTech/Google_Custom_Search/Algorithms/Array_Data_Retriever.php");
require_once("/home/bluecbhv/Jcuhelpers-WebTech/Google_Custom_Search/Algorithms/JSON_Pretty_Printer.php");
require_once("/home/bluecbhv/Jcuhelpers-WebTech/Google_Custom_Search/Algorithms/JSON_Encoder.php");

/***********************************************
	This class would filter the decoded JSON
	data & select only the required data.
************************************************/
class DecodedJSONDataFilter {
	private $encodedJSONData = NULL;
	private $prettyPrintedJSONData = NULL;
	
	private $searchResults = NULL;
	
	private $phpArray = NULL;
	private $phpArrayValuesToInsert = NULL;

	/************************************************************/
	
	function __construct() {
		date_default_timezone_set("Asia/Singapore");
	}
	
	function filterDecodedJSONData($decodedJSONData) {
		$adrObj = new ArrayDataRetriever();
		$this->phpArrayValuesToInsert = $adrObj->retrieveArrayData($decodedJSONData);
		$this->phpArray = $this->phpArrayValuesToInsert;
		
		$this->searchResults = array(
			"Date & Time Created" => date("d/M/Y - h:iA", time()),
			"Search_Results" => $this->phpArray
		);
		
		$jeObj = new JSONEncoder();
		$this->encodedJSONData = $jeObj->encodeJSONData($this->searchResults);
		
		$jppObj = new JSONPrettyPrinter();
		$this->prettyPrintedJSONData = $jppObj->prettyPrint($this->encodedJSONData);
		
		return $this->prettyPrintedJSONData;
	}
}
?>